package com.amat0urheu.pojo;

import com.alibaba.fastjson.annotation.JSONField;
import com.amat0urheu.util.generator.ShortUUID;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonView;
import lombok.Data;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Data
public class User {

    public Integer getUid() {
		return uid;
	}

	public void setUid(Integer uid) {
		this.uid = uid;
	}

	public String getUname() {
		return uname;
	}

	public void setUname(String uname) {
		this.uname = uname;
	}

	public String getUpassword() {
		return upassword;
	}

	public void setUpassword(String upassword) {
		this.upassword = upassword;
	}

	public String getRole() {
		return role;
	}

	public void setRole(String role) {
		this.role = role;
	}

	public Boolean getSex() {
		return sex;
	}

	public void setSex(Boolean sex) {
		this.sex = sex;
	}

	public String getSkill() {
		return skill;
	}

	public void setSkill(String skill) {
		this.skill = skill;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getUnit() {
		return unit;
	}

	public void setUnit(String unit) {
		this.unit = unit;
	}

	public String getSign() {
		return sign;
	}

	public void setSign(String sign) {
		this.sign = sign;
	}

	public Date getRegTime() {
		return regTime;
	}

	public void setRegTime(Date regTime) {
		this.regTime = regTime;
	}

	public Integer getWeb() {
		return web;
	}

	public void setWeb(Integer web) {
		this.web = web;
	}

	public Integer getPwn() {
		return pwn;
	}

	public void setPwn(Integer pwn) {
		this.pwn = pwn;
	}

	public Integer getCrypto() {
		return crypto;
	}

	public void setCrypto(Integer crypto) {
		this.crypto = crypto;
	}

	public Integer getMisc() {
		return misc;
	}

	public void setMisc(Integer misc) {
		this.misc = misc;
	}

	public Integer getRe() {
		return re;
	}

	public void setRe(Integer re) {
		this.re = re;
	}

	public Integer getOther() {
		return other;
	}

	public void setOther(Integer other) {
		this.other = other;
	}

	public Integer getScore() {
		return score;
	}

	public void setScore(Integer score) {
		this.score = score;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public Integer getLevel() {
		return level;
	}

	public void setLevel(Integer level) {
		this.level = level;
	}

	public Integer getRank() {
		return rank;
	}

	public void setRank(Integer rank) {
		this.rank = rank;
	}

	@TableId
    private Integer uid;
    private String uname;
    @JSONField(serialize=false)
    private String upassword;
    private String role;
    private Boolean sex;
    private String skill;
    private String email;
    private String unit;
    private String sign;
    private Date regTime;
    private Integer web;
    private Integer pwn;
    private Integer crypto;
    private Integer misc;
    private Integer re;
    private Integer other;
    private Integer score;

    private String title;
    private Integer level;
	private Integer rank;
	private String teamname;
	public String getTeamName() {
		return teamname;
	}

	public void setTeamName(String teamname) {
		this.teamname = teamname;
	}



	@Override
	public String toString() {
		return "User{" +
				"uid=" + uid +
				", uname='" + uname + '\'' +
				", upassword='" + upassword + '\'' +
				", role='" + role + '\'' +
				", sex=" + sex +
				", skill='" + skill + '\'' +
				", email='" + email + '\'' +
				", unit='" + unit + '\'' +
				", sign='" + sign + '\'' +
				", regTime=" + regTime +
				", web=" + web +
				", pwn=" + pwn +
				", crypto=" + crypto +
				", misc=" + misc +
				", re=" + re +
				", other=" + other +
				", score=" + score +
				", title='" + title + '\'' +
				", level=" + level +
				", rank=" + rank +
				", teamName=" + teamname +
				'}';
	}


	public User() {}

    public User(Integer uid) {
        this.uid = uid;
    }

    public User(String uname, String upassword) {
        this.uname = uname;
        this.upassword = upassword;
    }

    public void setRankTitle() {
        List<Title> titles = new ArrayList<>();
        titles.add(new Title("小白-Ⅴ", 0, 0, 100));
        titles.add(new Title("小白-Ⅳ", 0, 100, 200));
        titles.add(new Title("小白-Ⅲ", 0, 200, 300));
        titles.add(new Title("小白-Ⅲ", 0, 300, 400));
        titles.add(new Title("小白-Ⅱ", 0, 400, 500));
        titles.add(new Title("小白-Ⅰ", 0, 500, 800));
        titles.add(new Title("脚本小子-Ⅲ", 1, 800, 1100));
        titles.add(new Title("脚本小子-Ⅱ", 1, 1100, 1400));
        titles.add(new Title("脚本小子-Ⅰ", 1, 1400, 2000));
        titles.add(new Title("脚本选手-Ⅲ", 1, 2000, 2400));
        titles.add(new Title("脚本选手-Ⅱ", 1, 2400, 2800));
        titles.add(new Title("脚本选手-Ⅰ", 1, 2800, 3600));
        titles.add(new Title("脚本高手-Ⅲ", 1, 3600, 4100));
        titles.add(new Title("脚本高手-Ⅱ", 1, 4100, 4600));
        titles.add(new Title("脚本高手-Ⅰ", 1, 4600, 5600));
        titles.add(new Title("工程师-Ⅲ", 2, 5600, 6600));
        titles.add(new Title("工程师-Ⅱ", 2, 6600, 8100));
        titles.add(new Title("工程师-Ⅰ", 2, 8100, 10000));
        titles.add(new Title("研究员-Ⅲ", 3, 10000, 12000));
        titles.add(new Title("研究员-Ⅱ", 3, 12000, 15000));
        titles.add(new Title("研究员-Ⅰ", 3, 15000, 20000));
        titles.add(new Title("黑客-Ⅲ", 4, 20000, 25000));
        titles.add(new Title("黑客-Ⅱ", 4, 25000, 35000));
        titles.add(new Title("黑客-Ⅰ", 4, 35000, 50000));
        titles.add(new Title("极客-Ⅲ", 5, 50000, 60000));
        titles.add(new Title("极客-Ⅱ", 5, 70000, 80000));
        titles.add(new Title("极客-Ⅰ", 5, 80000, 100000));
        titles.add(new Title("飞升者", 6, 100000, Integer.MAX_VALUE));

        for (Title title : titles) {
            if (score >= title.getMaxScore()) {
            } else {
                this.title = title.getTitle();
                this.level = title.getLevel();
                break;
            }
        }

    }

}
